! Open folder for Book Style record
! If message has a file name, open that file in the folder
gcapp.set "messageVisible","false"
gcapp.get doc,frontDocument
doc.get recRef,"keyRecord"
if @recRef.class!="BookRecord"
  Beep
  exit
endif

#fldr=@recRef.saveFolder
if #fldr=""
  UserOption "#var","The folder field for this book style record is empty.","","OK"
  exit
endif

! if user just changed name, it might not get here
! but usually won't be correct file name anyway
#root=@gcapp.scriptMessage
if #root!=""
  Replace "#root","/","_",#root
  Replace "#root","'","-",#root
  Replace "#root",quote,"-",#root
  Replace "#root"," ","_",#root
  #fldr&="/"&#root&".pdf"
endif

! open folder or file
RevealInFinder #fldr
